package xyf.p11.other.prepoststatistics;

/**
 * ClassName: M0503_Reverse
 * Description:
 * Author: xyf
 * Date: 9/9/22 10:16 AM
 * Version: 1.0
 **/
public class M0503_Reverse
{
    public int reverseBits(int num)
    {
        int current = 0;
        int reverse = 0;
        int max = 0;
        for (int i = 0; i < 32; i++)
        {
            if ((num & 1) == 1)
            {
                current += 1;
                reverse += 1;
            }
            else
            {
                reverse = current + 1;
                current = 0;
            }
            max = Math.max(max, reverse);
            num = num >> 1;
        }
        return max;
    }
}